<template>
	<view class="userPopupShow" v-if="userPopupShow">
		<view class="userPopupShow-mask" @click="closeUserPopup"></view>
		<view class="userPopupShow-c">
			<view class="userPopupShow-header">图标设置</view>
			<view class="userPopupShow-close" @click="closeUserPopup">
				<u-icon name="close" color="#909399" size="20"></u-icon>
			</view>
			<scroll-view class="userPopupShow-c-list" scroll-y="true" >
				<view class="userPopupShow-c-list-item customize" @click="upload">
					<view class="userPopupShow-c-list-item-img">
						<uni-icons custom-prefix="iconfont" color="#fff" type="icon-zidingyiquyu" size="25"></uni-icons>
					</view>
					<view class="userPopupShow-c-list-item-tx">
						自定义
					</view>
				</view>
				<view class="userPopupShow-c-list-item" v-for="it in list" :key="it.id" @click="sure(it)" >
					<view class="userPopupShow-c-list-item-img">
						<image :src="it.img" mode=""></image>
					</view>
					<view class="userPopupShow-c-list-item-tx" :style="it.name?'':'opacity:0'">
						  {{it.name}}
					</view>
				
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import {
		tree_icon
	} from '@/common/http/api.js'
	import {
		uploadImg
	} from '@/common/upload.js'
	export default {
		data(){
			return {
				userPopupShow: false,
				params:{
					page: 1
				},
				list: []
			}
		},
		methods:{
			closeUserPopup(){
				this.userPopupShow = false
			},
			show(){
				this.userPopupShow = true
				tree_icon().then(res=>{
					this.list = res.data
				})
			},
			sure(e){
				this.$emit('change', e)
				this.closeUserPopup()
			},
			upload(){
				uploadImg().then(res=>{
		
					this.sure({type: 1, img: res.data.url})
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.userPopupShow {
		width: 100vw;
		height: 100vh;
		position: fixed;
		top: 0;
		right: 0;
		z-index: 999999;
		.userPopupShow-mask {
			width: 100%;
			height: 100%;
			background: rgba(0,0,0,0.2);
		}
		.userPopupShow-c {
			width: 600rpx;
			height: fit-content;
			position: absolute;
			top: 0;
			left: 0;
			right: 0;
			bottom: 0;
			margin: auto;
			z-index: 2;
			background: white;
			border-radius: 30rpx;
			box-shadow: 0 0 12rpx #e4e4e4;
			.userPopupShow-header {
				text-align: center;
				font-size: 28rpx;
				padding: 10rpx 0;
			}
			.userPopupShow-close {
				display: flex;
				justify-content: flex-end;
				box-sizing: border-box;
				padding-right: 20rpx;
				padding-top: 20rpx;
				position: absolute;
				right: 0;
				top: 0;
			}
			.userPopupShow-c-list {
				width: 100%;
				padding: 20rpx;
				height: 620rpx;
				overflow-y: scroll;
				box-sizing: border-box;
				display: flex;
				flex-wrap: wrap;
			}
		}
		
	}
	
	.userPopupShow-c-list-item {
		width: 112.5rpx;
		display: inline-block;
		margin-bottom: 20rpx;
		margin-right: 30rpx;
		&:nth-child(4n) {
			margin-right: 0;
		}
		.userPopupShow-c-list-item-img {
			width: 100%;
			height: 112.5rpx;
			margin-bottom: 5rpx;
			image {
				width: 100%;
				height: 100%;
				border-radius: 10rpx;
			}
		}
		.userPopupShow-c-list-item-tx {
			font-size: 24rpx;
			overflow: hidden;
			white-space: nowrap;
			text-overflow: ellipsis;
			text-align: center;
		}
	}
	.customize {
		.userPopupShow-c-list-item-img {
			background: #e7e7e7;
			border-radius: 10rpx;
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}
</style>